home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src / lib / asm / windowfunc.s < prev   
Encoding:
Text File  |  1998-10-04  |  3.2 KB  |  183 lines

  1. ;
  2. ; windowfunc.s -- an ACE linked library module: WINDOW(n).
  3. ; Copyright (C) 1998 David Benn
  4. ; This program is free software; you can redistribute it and/or
  5. ; modify it under the terms of the GNU General Public License
  6. ; as published by the Free Software Foundation; either version 2
  7. ; of the License, or (at your option) any later version.
  8. ;
  9. ; This program is distributed in the hope that it will be useful,
  10. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. ; GNU General Public License for more details.
  13. ;
  14. ; You should have received a copy of the GNU General Public License
  15. ; along with this program; if not, write to the Free Software
  16. ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  17. ;
  18. ; Author: David J Benn
  19. ;   Date: 19th March 1994,
  20. ;      13th August 1994,
  21. ;      12th March 1995
  22. ;
  23. ; registers d0-d6 and a0-a3 are modified by some of the following. BEWARE!
  24. ;
  25. ; a4,a5 are used by link/unlk.
  26. ; a6 is library base holder.
  27. ; a7 is stack pointer. 
  28. ; d7 is used for array index calculations.
  29. ;
  30.  
  31. ; * CONSTANTS *
  32. Width        equ 8
  33. Height        equ 10
  34. cp_x        equ 36
  35. cp_y        equ 38
  36. BitMap        equ 184
  37. Depth        equ 5
  38. Font        equ 52
  39. tf_YSize    equ 20
  40. tf_XSize    equ 24
  41. lib_Version    equ 20
  42.  
  43.     xdef    _windowfunc
  44.  
  45.        ; external references
  46.     xref    _Wdw_id
  47.     xref    _Wdw
  48.     xref    _RPort
  49.     xref    _Scrn
  50.     xref    _stdout
  51.     xref    _fgdpen
  52.     xref    _bgpen
  53.     xref    _get_selected_wdw
  54.  
  55.     SECTION windowfunc_code,CODE
  56.  
  57. ;
  58. ; WINDOW(n) - returns info' about the current output window. d0=n.
  59. ;        - return value is a long integer in d0.    
  60. ;
  61. _windowfunc:
  62.     cmpi.w    #0,d0
  63.     beq    _window0
  64.     cmpi.w    #1,d0
  65.     beq    _window1
  66.     cmpi.w    #2,d0
  67.     beq    _window2
  68.     cmpi.w    #3,d0
  69.     beq    _window3
  70.     cmpi.w    #4,d0
  71.     beq    _window4
  72.     cmpi.w    #5,d0
  73.     beq    _window5
  74.     cmpi.w    #6,d0
  75.     beq    _window6
  76.     cmpi.w    #7,d0
  77.     beq    _window7
  78.     cmpi.w    #8,d0
  79.     beq    _window8
  80.     cmpi.w    #9,d0
  81.     beq    _window9
  82.     cmpi.w    #10,d0
  83.     beq    _window10
  84.     cmpi.w    #11,d0
  85.     beq    _window11
  86.     cmpi.w    #12,d0
  87.     beq    _window12
  88.     cmpi.w    #13,d0
  89.     beq    _window13
  90.     
  91.     moveq    #0,d0
  92.     rts            ; none of the above
  93.  
  94. _window0:
  95.     movem.l    d1-d7/a0-a6,-(sp)
  96.     jsr    _get_selected_wdw
  97.     movem.l    (sp)+,d1-d7/a0-a6
  98.     rts
  99.  
  100. _window1:
  101.     move.w    _Wdw_id,d0    ; Wdw-id
  102.     ext.l    d0
  103.     rts
  104.  
  105. _window2:
  106.     movea.l    _Wdw,a0
  107.     move.w    Width(a0),d0    ; current Wdw width
  108.     ext.l    d0
  109.     rts
  110.  
  111. _window3:
  112.     movea.l    _Wdw,a0
  113.     move.w    Height(a0),d0    ; current Wdw height
  114.     ext.l    d0
  115.     rts
  116.  
  117. _window4:
  118.     move.l    _RPort,a0
  119.     move.w    cp_x(a0),d0    ; next x coordinate to be used
  120.     ext.l    d0    
  121.     rts
  122.  
  123. _window5:
  124.     move.l    _RPort,a0
  125.     move.w    cp_y(a0),d0    ; next y coordinate to be used
  126.     ext.l    d0    
  127.     rts
  128.  
  129. _window6:
  130.     movea.l    _Scrn,a0
  131.     adda.l    #BitMap,a0    ; BitMap
  132.     move.b    Depth(a0),d0    ; depth
  133.     ext.w    d0
  134.     ext.l    d0
  135.     moveq    #1,d1        
  136. _calc_max_colr_id:
  137.     lsl.l    #1,d1
  138.     subq    #1,d0        
  139.     cmpi.l    #0,d0
  140.     bgt.s    _calc_max_colr_id
  141.     subq    #1,d1
  142.     move.l    d1,d0        ; max-color-id = 2^depth - 1
  143.     rts
  144.  
  145. _window7:
  146.     move.l    _Wdw,d0        ; Intuition Wdw address
  147.     rts
  148.  
  149. _window8:
  150.     move.l    _RPort,d0    ; Intuition RPort address
  151.     rts
  152.  
  153. _window9:
  154.     move.l    _stdout,d0    ; file handle    
  155.     rts
  156.  
  157. _window10:
  158.     move.w    _fgdpen,d0
  159.     ext.l    d0        ; foreground pen
  160.     rts
  161.  
  162. _window11:
  163.     move.w    _bgpen,d0
  164.     ext.l    d0        ; background pen
  165.     rts
  166.  
  167. _window12:
  168.     movea.l    _RPort,a0
  169.     movea.l    Font(a0),a0
  170.     move.w    tf_XSize(a0),d0    
  171.     ext.l    d0        ; font width
  172.     rts
  173.  
  174. _window13:
  175.     movea.l    _RPort,a0
  176.     movea.l    Font(a0),a0
  177.     move.w    tf_YSize(a0),d0    
  178.     ext.l    d0        ; font height
  179.     rts
  180.  
  181.     END
  182.